package com.smartstate.dataArchives.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartstate.dataArchives.dto.PageDTO;
import com.smartstate.dataArchives.dto.UserDTO;
import com.smartstate.dataArchives.entity.User;
import com.smartstate.dataArchives.service.UserService;
import com.smartstate.dataArchives.vo.UserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = {"用户控制器"})
@RequestMapping("/User")
public class UserController {
  @Resource
  private UserService service;

  @PostMapping ("/saveOrUpdate")
  @ApiOperation(value = "新增或修改")
  public boolean saveOrUpdate(@RequestBody User item) {
    return service.saveOrUpdate(item);
  }

  @PostMapping ("/removeByIds")
  @ApiOperation(value = "根据ID批量删除")
  public boolean removeByIds(@RequestBody List<Integer> item) {
    return service.removeByIds(item);
  }

  @PostMapping ("/removeById")
  @ApiOperation(value = "根据ID删除")
  public boolean removeById(@RequestParam Integer id) {
    return service.removeById(id);
  }

  @PostMapping ("/getUserBySpec")
  @ApiOperation(value = "单表分页查询")
  public Page<User> getUserBySpec(@RequestBody PageDTO<User> pageDTO) {
    return service.queryAllPageByDTO(pageDTO);
  }

  @PostMapping ("/getAllUserAndDepartment")
  @ApiOperation(value = "查询人员及部门")
  public List<UserVO> getAllUserAndDepartment(@RequestBody UserDTO item) {
    return service.getAllUserAndDepartment(item);
  }

  @GetMapping("/getSerialCode")
  @ApiOperation("获取序列号")
  public String getSerialCode(String name){
    return service.getSerialCode(name);
  }

  @PostMapping("/setRedisValue")
  @ApiOperation("redis测试")
  public Boolean setRedisValue(@RequestParam String value) {
    return service.setRedisValue(value);
  }


}
